xtset guregion year
sort guregion year

* Generate necessary variables
gen populationbythousand =population/1000
* Recycling rate calculations
gen recyrate = recycled / generated
gen recyrate100 = recyrate * 100
gen recyrate100lag = L1.recyrate100 

* Waste management efficiency variables
gen recycledyear = recycled * 365
gen recycledyearcap = recycledyear / population
gen recycledyearcaplag = L1.recycledyearcap

* Financial & policy monitoring variables
gen govmonitorcap = govmonitor / population
gen govmonitorcap1000 = govmonitorcap * 1000
gen civilreportcap = civilreport / population
gen civilreportcap1000 = civilreportcap * 1000
gen budgetpercap = budgetind / population

* Waste generation per capita
gen generatedyear = generated * 365
gen generatedyearcap = generatedyear / population
gen generatedyearcaplag = L1.generatedyearcap

* Bag sales-related variables
gen bagsalescap = bagsales / population
gen bagsalescaplag = L1.bagsalescap
gen bagsalescaplagmil = bagsalescaplag * 1000000
rename bagsalescaplagmil bagsalescaplagmillag
gen bagsalesog=bagsales*1000000
gen bagsalesogcap=bagsalesog/population
gen bagsalesogcaplag=L1.bagsalesogcap
gen bagsalesogcapdollar=bagsalesogcap/1216
gen bagsalesogcapdollarlag=L1.bagsalesogcapdollar

* Area-related variables
gen govmonitorarea = govmonitor / area

* Convert variables for scaling
gen budgetind100 = budgetind * 100
gen recycledyearcapkilo = recycledyearcap * 1000
gen recycledyearcaplagkilo = recycledyearcaplag * 1000

* Define final variables for regression
global y1list bagsalesogcapdollarlag
global y2list recycledyearcaplagkilo
global y3list recyrate100lag
global x2list govmonitorarea rewardum compdum bothpolicy civilreportcap1000 budgetind100 populationbythousand


* ========== PCSE ORIGINAL ==========
xtpcse bagsalesogcapdollarlag govmonitorarea rewardum compdum bothpolicy civilreportcap1000 budgetind100 populationbythousand 
xtpcse recycledyearcaplagkilo govmonitorarea rewardum compdum bothpolicy civilreportcap1000 budgetind100 populationbythousand 
xtpcse recyrate100lag govmonitorarea rewardum compdum bothpolicy civilreportcap1000 budgetind100 populationbythousand 


*========== PCSE WITHOUT CONTROL ==========
xtpcse bagsalesogcapdollarlag govmonitorarea rewardum compdum bothpolicy
xtpcse recycledyearcaplagkilo govmonitorarea rewardum compdum bothpolicy
xtpcse recyrate100lag govmonitorarea rewardum compdum bothpolicy

* ========== SEEMINGLY UNRELATED REGRESSION (SUR) ==========
describe $y1list $y2list $y3list $x2list
summarize $y1list $y2list $y3list $x2list

* SUR model
sureg ($y1list $x2list) ($y2list $x2list) ($y3list $x2list), corr

* ========== SEEMINGLY UNRELATED REGRESSION WITHOUT CONTROL ==========
global x2list govmonitorarea rewardum compdum bothpolicy
describe $y1list $y2list $y3list $x2list
summarize $y1list $y2list $y3list $x2list

* SUR model without control
sureg ($y1list $x2list) ($y2list $x2list) ($y3list $x2list), corr

* End of script
exit
